﻿using System;
using System.Collections.Generic;
using Castle.ActiveRecord;
using NHibernate.Expression;

namespace Hadlow.Jobvertizer.Models
{
    [ActiveRecord]
    public class Poster : Entity
    {
        string name;

        [Property]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        string contactName;

        [Property(SqlType="Text")]
        public string ContactName
        {
            get { return contactName; }
            set { contactName = value; }
        }

        IList<Job> jobs = new List<Job>();

        [HasMany(Cascade=ManyRelationCascadeEnum.All)]
        public IList<Job> Jobs
        {
            get { return jobs; }
            set { jobs = value; }
        }

        IList<PosterUser> posterUsers = new List<PosterUser>();

        [HasMany(Cascade = ManyRelationCascadeEnum.AllDeleteOrphan)]
        public IList<PosterUser> PosterUsers
        {
            get { return posterUsers; }
            set { posterUsers = value; }
        }

        CreditCard creditCard;

        [BelongsTo("CreditCardId")]
        public CreditCard CreditCard
        {
            get { return creditCard; }
            set { creditCard = value; }
        }

        public override string ToString()
        {
            return this.name;
        }
    }
}
